package com.gg.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Locale;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

public class ConcurrentUser implements UserIdentifier {

	private String userId;
	private HttpServletResponse response;

	public ConcurrentUser(String userId, HttpServletResponse response) {
		this.userId = userId;
		this.response = response;
	}

	public void send(String message) throws IOException {
		try {
			response.getWriter().println(message);
			response.getWriter().flush();
			
		} catch(NullPointerException e) {
			throw new UserDisconnectException(e);
		}
	}
	
	public String getId() {
		return this.userId;
	}

	public boolean sameUser(UserIdentifier identifier) {
		return userId.equals(identifier.getId());
	}
}
